package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.system.domain.BotLlmConfig;
import com.ruoyi.system.service.IBotLlmConfigService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 大模型基础配置Controller
 *
 * @author gitee
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/llmConfig")
public class BotLlmConfigController extends BaseController
{
    @Resource
    private IBotLlmConfigService botLlmConfigService;

    /**
     * 查询大模型基础配置列表
     */
    @RequiresPermissions("system:llmConfig:list")
    @GetMapping("/list")
    public TableDataInfo list(PageDomain page, BotLlmConfig botLlmConfig)
    {
        Page mybatisPage = startPage(page);
        List<BotLlmConfig> list = botLlmConfigService.selectBotLlmConfigList(mybatisPage, botLlmConfig);
        return getDataTable(mybatisPage, list);
    }

    /**
     * 导出大模型基础配置列表
     */
    @RequiresPermissions("system:llmConfig:export")
    @Log(title = "大模型基础配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BotLlmConfig botLlmConfig)
    {
        List<BotLlmConfig> list = botLlmConfigService.selectBotLlmConfigList(botLlmConfig);
        ExcelUtil<BotLlmConfig> util = new ExcelUtil<BotLlmConfig>(BotLlmConfig.class);
        util.exportExcel(response, list, "大模型基础配置数据");
    }

    /**
     * 获取大模型基础配置详细信息
     */
    @RequiresPermissions("system:llmConfig:query")
    @GetMapping(value = "/{llmId}")
    public AjaxResult getInfo(@PathVariable("llmId") Long llmId)
    {
        return success(botLlmConfigService.selectBotLlmConfigByLlmId(llmId));
    }

    /**
     * 新增大模型基础配置
     */
    @RequiresPermissions("system:llmConfig:add")
    @Log(title = "大模型基础配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BotLlmConfig botLlmConfig)
    {
        return toAjax(botLlmConfigService.insertBotLlmConfig(botLlmConfig));
    }

    /**
     * 修改大模型基础配置
     */
    @RequiresPermissions("system:llmConfig:edit")
    @Log(title = "大模型基础配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BotLlmConfig botLlmConfig)
    {
        return toAjax(botLlmConfigService.updateBotLlmConfig(botLlmConfig));
    }

    /**
     * 删除大模型基础配置
     */
    @RequiresPermissions("system:llmConfig:remove")
    @Log(title = "大模型基础配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{llmIds}")
    public AjaxResult remove(@PathVariable Long[] llmIds)
    {
        return toAjax(botLlmConfigService.deleteBotLlmConfigByLlmIds(llmIds));
    }
}
